//
//  LYYGuessSecondCollectionViewCell.m
//  Icar
//
//  Created by dllo on 15/10/19.
//  Copyright © 2015年 小龙侠. All rights reserved.
//

#import "LYYGuessSecondCollectionViewCell.h"

#define View_Width self.userface.frame.size.width + 10
@implementation LYYGuessSecondCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self creatCell];
    }
    return self;
}

- (void)creatCell{
    //用户头像
    self.userface = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5,50, 50)];
    self.userface.layer.cornerRadius = 25;
    self.userface.layer.masksToBounds = YES;
    [self.contentView addSubview:self.userface];
    
    //昵称
    self.nickNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.userface.frame.size.width + 10, 5, self.frame.size.width - View_Width - 20, 30)];
    self.nickNameLabel.numberOfLines = 0;
    self.nickNameLabel.textColor = [UIColor colorWithWhite:0.902 alpha:1.000];
    [self.contentView addSubview:self.nickNameLabel];
    
    //标题
    self.titleLabel = [[UILabel alloc]init];
    [self.titleLabel setTextColor:[UIColor blackColor]];
    self.titleLabel.numberOfLines = 0;
    [self.contentView addSubview:self.titleLabel];
    
    //date
    self.dateLabel = [[UILabel alloc]init];
    [self.contentView addSubview:self.dateLabel];
    [self.dateLabel setTextColor:[UIColor colorWithWhite:0.702 alpha:1.000]];
    
    //replay
    self.replyCount = [[UILabel alloc]init];
    [self.replyCount setTextColor:[UIColor colorWithWhite:0.702 alpha:1.000]];
    [self.contentView addSubview:self.replyCount];
    
    //flag
    self.flagView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.flagView];
}



- (void)getSecondModel:(DENForumModel *)model{
    //头像
    [self.userface sd_setImageWithURL:[NSURL URLWithString:model.userface] placeholderImage:PLACEHOLDER];
    //昵称
    self.nickNameLabel.text = [NSString stringWithFormat:@"%@在%@发表了帖子",model.nickname,model.forum];
    self.nickNameLabel.textColor = [UIColor colorWithWhite:0.702 alpha:1.000];
    NSMutableAttributedString *mutableString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@在%@发表了帖子",model.nickname,model.forum]];
    [mutableString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:0.47 blue:0.89 alpha:1] range:NSMakeRange(0,model.nickname.length)];
    [mutableString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:0.47 blue:0.89 alpha:1] range:NSMakeRange(model.nickname.length+1,model.forum.length)];
    self.nickNameLabel.attributedText = mutableString;
    //标题
    self.titleLabel.text = model.topic;
    self.dateLabel.text = model.datatime;
    
    
    self.replyCount.text = [NSString stringWithFormat:@"%ld回复  %ld阅读",model.replycount,model.view];
    
    [self.dateLabel setFrame:CGRectMake(self.userface.frame.size.width , HEIGHT(90), WIDTH(130), HEIGHT(30))];
    [self.replyCount setFrame:CGRectMake(self.userface.frame.size.width + WIDTH(200), HEIGHT(90), WIDTH(130), HEIGHT(30))];
    
    if (SCREEN_HEIGHT == 736) {
        model.topicHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:18.]];
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:18.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:14.]];
        
        
    }else if (SCREEN_HEIGHT == 667){
        model.topicHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:16.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:16.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:12.]];
        
    }else if (SCREEN_HEIGHT == 568){
        model.topicHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:14.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:10.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:10.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:10.]];
        
        
    }else if (SCREEN_HEIGHT == 480){
        model.topicHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:12.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:8.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:8.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:8.]];
        
    }
    
    [self.titleLabel setFrame:CGRectMake(View_Width, 40, self.nickNameLabel.frame.size.width, model.topicHeight)];
    
}

- (void)getNoImageHotModel:(LYYAllModel *)model{
    
    [self.userface sd_setImageWithURL:[NSURL URLWithString:model.userface] placeholderImage:PLACEHOLDER];
    //昵称
    self.nickNameLabel.text = [NSString stringWithFormat:@"%@",model.nickname];
    self.nickNameLabel.textColor = [UIColor colorWithWhite:0.702 alpha:1.000];
    NSMutableAttributedString *mutableString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",model.nickname]];
    [mutableString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:0.47 blue:0.89 alpha:1] range:NSMakeRange(0,model.nickname.length)];
    self.nickNameLabel.attributedText = mutableString;
    //标题
    self.titleLabel.text = model.title;
    
    self.replyCount.text = [NSString stringWithFormat:@"%ld回复  %ld阅读",model.replyCount,model.view];
    
    if (model.images.count == 0) {
        [self.replyCount setFrame:CGRectMake(self.userface.frame.size.width + WIDTH(200), HEIGHT(90), WIDTH(130), HEIGHT(30))];
    }else{
        [self.replyCount setFrame:CGRectMake(self.userface.frame.size.width + WIDTH(200), HEIGHT(165), WIDTH(130), HEIGHT(30))];
    }

    if (SCREEN_HEIGHT == 736) {
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:18.]];
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:18.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:14.]];
        
        
    }else if (SCREEN_HEIGHT == 667){
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:16.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:16.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:12.]];
        
    }else if (SCREEN_HEIGHT == 568){
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:14.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:10.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:10.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:10.]];
        
        
    }else if (SCREEN_HEIGHT == 480){
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:12.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:8.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:8.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:8.]];
        
    }
    
    [self.titleLabel setFrame:CGRectMake(View_Width, 40, self.nickNameLabel.frame.size.width, model.titleHeight)];
    
}

- (void)getJModel:(LYYAllModel *)model{
    
    [self.userface sd_setImageWithURL:[NSURL URLWithString:model.userface] placeholderImage:PLACEHOLDER];
    //昵称
    self.nickNameLabel.text = [NSString stringWithFormat:@"%@",model.nickname];
    self.nickNameLabel.textColor = [UIColor colorWithWhite:0.702 alpha:1.000];
    NSMutableAttributedString *mutableString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",model.nickname]];
    [mutableString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:0.47 blue:0.89 alpha:1] range:NSMakeRange(0,model.nickname.length)];
    self.nickNameLabel.attributedText = mutableString;
    //标题
    self.titleLabel.text = model.title;
    
    self.replyCount.text = [NSString stringWithFormat:@"%ld回复  %ld阅读",model.replyCount,model.view];
    
    if (model.images.count == 0) {
        [self.replyCount setFrame:CGRectMake(self.userface.frame.size.width + WIDTH(200), HEIGHT(90), WIDTH(130), HEIGHT(30))];
    }else{
        [self.replyCount setFrame:CGRectMake(self.userface.frame.size.width + WIDTH(200), HEIGHT(165), WIDTH(130), HEIGHT(30))];
    }
    
    if (SCREEN_HEIGHT == 736) {
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:18.]];
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:18.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:14.]];
        
        
    }else if (SCREEN_HEIGHT == 667){
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:16.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:16.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:12.]];
        
    }else if (SCREEN_HEIGHT == 568){
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:14.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:10.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:10.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:10.]];
        
        
    }else if (SCREEN_HEIGHT == 480){
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:12.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:8.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:8.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:8.]];
        
    }
    
    [self.titleLabel setFrame:CGRectMake(View_Width, 40, self.nickNameLabel.frame.size.width, model.titleHeight)];
    
}

- (void)getAskModel:(LYYAllModel *)model{
   
    [self.userface sd_setImageWithURL:[NSURL URLWithString:model.userface] placeholderImage:PLACEHOLDER];
    //昵称
    self.nickNameLabel.text = [NSString stringWithFormat:@"%@",model.nickname];
    self.nickNameLabel.textColor = [UIColor colorWithWhite:0.702 alpha:1.000];
    NSMutableAttributedString *mutableString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",model.nickname]];
    [mutableString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:0.47 blue:0.89 alpha:1] range:NSMakeRange(0,model.nickname.length)];
    self.nickNameLabel.attributedText = mutableString;
    //标题
    self.titleLabel.text = model.title;
    
    self.replyCount.text = [NSString stringWithFormat:@"%ld答/%ld阅",model.replyCount,model.view];
    NSArray *str = [self.replyCount.text componentsSeparatedByString:@"/"];
    NSString *titleStr = str[0];
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%ld答/%ld阅",model.replyCount,model.view]];
    [string addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(0, titleStr.length)];
    self.replyCount.attributedText = string;
    if (model.images.count == 0) {
        [self.replyCount setFrame:CGRectMake(self.userface.frame.size.width + WIDTH(250), HEIGHT(90), WIDTH(130), HEIGHT(30))];
    }else{
        [self.replyCount setFrame:CGRectMake(self.userface.frame.size.width + WIDTH(250), HEIGHT(165), WIDTH(130), HEIGHT(30))];
    }
    
    if (SCREEN_HEIGHT == 736) {
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:18.]];
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:18.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:14.]];
        
        
    }else if (SCREEN_HEIGHT == 667){
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:16.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:16.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:12.]];
        
    }else if (SCREEN_HEIGHT == 568){
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:14.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:10.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:10.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:10.]];
        
        
    }else if (SCREEN_HEIGHT == 480){
        model.titleHeight = [StringWithHeight HeightWithText:self.titleLabel.text width:self.nickNameLabel.frame.size.width font:[UIFont systemFontOfSize:12.]] ;
        [self.nickNameLabel setFont:[UIFont systemFontOfSize:8.]];
        [self.titleLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:8.]];
        [self.replyCount setFont:[UIFont systemFontOfSize:8.]];
        
    }
    
    [self.titleLabel setFrame:CGRectMake(View_Width, 40, self.nickNameLabel.frame.size.width, model.titleHeight)];
}

@end
